<!--#
layout("/layouts/store.html"){
#-->
<header class="header navbar bg-white shadow">
    <div class="btn-group tool-button">
        <a class="btn btn-primary navbar-btn" href="${base}/store/customer" id="goBack" data-pjax><i class="ti-angle-left"></i>${msg['globals.button.back']}</a>
    </div>
</header>

<div class="content-wrap">
    <div class="wrapper" style="min-height:500px;">
        <section class="panel panel-form">
            <form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
                  action="${base}/store/customer/addDo" method="post">
                <div class="row mb10 mt10">
                    <div class="col-lg-12">
                        <div class="form-group">
                            <label class="col-sm-2 control-label text-default">上传图片要求:</label>
                            <div class="col-sm-8">
                                <p class="form-control-static text-danger">1.图片尺寸不得小于476px*357px</p>
                                <p class="form-control-static text-danger">2.长与宽的比例为4:3</p>
                                <p class="form-control-static text-danger">3.图片大小不得大于2M</p>
                                <p class="form-control-static text-danger">4.格式:支持JPG,JPEG</p>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="imageUrl" class="col-sm-2 control-label">客户头像</label>
                            <div class="col-sm-8">
                                <div id="div_imageUrl_queue"></div>
                                <div>
                                    <input id="file_upload_imageUrl" name="file_upload_imageUrl" type="file" multiple="false">
                                </div>
                                <div id="div_imageUrl_img" style="padding: 5px;"></div>
                                <input type="hidden" id="imageUrl" name="imageUrl" value=""/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="name" class="col-sm-2 control-label">${msg['store.customer.column.name']}</label>
                            <div class="col-sm-8">
                                <input type="text" id="name" class="form-control" name="name" data-parsley-required="true" placeholder="${msg['store.customer.column.name']}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="gender" class="col-sm-2 control-label">${msg['store.customer.column.gender']}</label>
                            <div class="col-sm-8">
                                <label>
                                <input  type="radio" id="gender"  name="gender" value="男">男</label>
                                <label>
                                <input  type="radio"  name="gender" value="女">女</label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="mobile" class="col-sm-2 control-label">${msg['store.customer.column.mobile']}</label>
                            <div class="col-sm-8">
                                <input type="text" id="mobile" class="form-control" name="mobile" data-parsley-required="true" data-parsley-phone placeholder="${msg['store.customer.column.mobile']}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="emial" class="col-sm-2 control-label">${msg['store.customer.column.emial']}</label>
                            <div class="col-sm-8">
                                <input type="text" id="emial" class="form-control" name="emial" data-parsley-type="email" placeholder="${msg['store.customer.column.emial']}">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-3"></div>
                <div class="col-lg-6">
                    <div class="form-group text-center">
                        <label></label>

                        <div>
                            <button class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="${msg['globals.button.submit.tip']}">${msg['globals.button.submit']}</button>
                        </div>
                    </div>
                </div>
            </form>
        </section>
    </div>
</div>
<script language="JavaScript">
    function clearImageUrlFile() {
        $("#div_imageUrl_img").empty();
        $("#div_imageUrl_queue").empty();
        $("#imageUrl").val("");
    }

    $(document).ready(function () {
        myForm.init();

        $('#file_upload_imageUrl').uploadifive({
            'auto': true,
            'multi': false,
            'width': '100%',
            'height': '35',
            'buttonText': "上传/修改",
            'fileType': 'image/jpg,image/jpeg,image/png',
            'fileSizeLimit': 1024,
            'queueSizeLimit': 1,
            'formData': {},
            'queueID': 'div_imageUrl_queue',
            'removeCompleted':true,
            'removeTimeout':0,
            'uploadScript': '${base}/open/file/upload/image',
            'onUploadComplete': function (file, data) {
                data = JSON.parse(data);
                if (data.code == 0) {
                    Toast.success(data.msg);
                    $("#div_imageUrl_img").html("<img src='" + data.data + "' style='width:150px;height:95px;'><i style=\"cursor: pointer\" class=\"fa fa-close\" onclick=\"$('#imageUrl').val('');$('#div_imageUrl_img').empty();\"></i>");
                    $("#imageUrl").val(data.data);
                } else {
                    clearImageUrlFile();
                    Toast.error(data.msg);
                }
            },
            'onSelect':function () {
                if($("#div_imageUrl_img").children().size() >= 1){
                    Toast.warning("只需上传一张");
                }
            }
        });
        $('#addForm').ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, form, options) {
                form.find("button:submit").button("loading");
            },
            success: function (data, statusText, xhr, form) {
                if (data.code == 0) {
                    Toast.success(data.msg);
                    form.resetForm();
                } else {
                    Toast.error(data.msg);
                }
                form.find("button:submit").button("reset");
            }
        });
    });
</script>
<!--#}#-->


